from django.apps import AppConfig
import logging

logger = logging.getLogger(__name__)


class EvaluationmineConfig(AppConfig):
    default_auto_field = 'django.db.models.BigAutoField'
    name = 'evaluationmine'
    
    def ready(self):
        """
        Django应用启动时自动初始化模型Handler
        """
        try:
            # 导入模型管理器，触发单例初始化
            from .model_manager import model_handler_singleton, is_model_available
            
            # 检查模型是否可用
            if is_model_available():
                logger.info("✓ 模型Handler在应用启动时初始化成功")
            else:
                logger.warning("⚠ 模型Handler初始化失败，将使用默认安全等级")
                
        except Exception as e:
            logger.error(f"✗ 应用启动时模型Handler初始化异常: {e}", exc_info=True)
    verbose_name = '安全评价管理'
